home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / A_Fast_Ric2064945102007.psc / SOLO SyntaxControl / Sample.txt < prev    next >
Text File  |  2007-05-10  |  3KB  |  87 lines

  1. Option Explicit
  2. '==========================================================
  3. ' An RTB Syntax Highlighting Control.
  4. ' Made by solomon manalo
  5. '==========================================================
  6. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  7.  
  8. Dim ex As String
  9.  
  10. Function ReadTextFileContents(filename As String) As String
  11.     Dim fnum As Integer, isOpen As Boolean
  12.     On Error GoTo Error_Handler
  13.     ' Get the next free file number.
  14.     fnum = FreeFile()
  15.     Open filename For Input As #fnum
  16.     ' If execution flow got here, the file has been open without error.
  17.     isOpen = True
  18.     ' Read the entire contents in one single operation.
  19.     ReadTextFileContents = Input(LOF(fnum), fnum)
  20.     ' Intentionally flow into the error handler to close the file.
  21. Error_Handler:
  22.     ' Raise the error (if any), but first close the file.
  23.     If isOpen Then Close #fnum
  24.     If Err Then Err.Raise Err.Number, , Err.Description
  25. End Function
  26.  
  27. Private Sub Command1_Click()
  28. Unload Me: End
  29. End Sub
  30.  
  31. Private Sub Command2_Click()
  32. OpenURL "http://www.solosoftware.co.nr", Me.hWnd
  33. End Sub
  34.  
  35. Private Sub Form_Load()
  36. Dim nL As String
  37. Call InitSyntaxEditor
  38.  
  39. nL = vbNewLine
  40. ex = "Option Explicit" & nL & _
  41.      "Public Const msg as Variant 'For Message Boxes" & nL & _
  42.      "Dim data as String" & nL & _
  43.      "Dim x as Double" & nL & nL & nL & _
  44.      "Private Sub Button1_Click()" & nL & _
  45.      "  s = " & Chr(34) & "Hello World!" & Chr(34) & nL & _
  46.      "  msg = MsgBox(s,vbYesNo + vbInformation," & Chr(34) & "Syntax" & Chr(34) & ")" & nL & _
  47.      "  If msg is vbYes then" & nL & _
  48.      "     'YES button is Clicked" & nL & _
  49.      "  Else" & nL & _
  50.      "     'NO button is Clicked" & nL & _
  51.      "  End if" & nL & _
  52.      "End Sub" & nL & _
  53.      "-----------------------------------------" & nL & _
  54.      "+ - * / \ = And Or Not Like is " & nL & _
  55.      "This is Normal Text"
  56.     
  57. SOLO_RTBSyntax1.Text = ex
  58. End Sub
  59.  
  60. Public Sub InitSyntaxEditor()
  61. 'You can change the Deafult syntax colors of this control by its
  62. 'properties in design time, or in coding style.
  63. With SOLO_RTBSyntax1
  64. 'Try to Uncomment this code...
  65. '===================================================
  66. '     .ColorOf_ReservedWords = vbRed
  67. '     .ColorOf_ProceduresORFunctions = vbBlue
  68. '     .ColorOf_Comments = vbYellow
  69. '     .ColorOf_Strings = vbGreen
  70. '===================================================
  71.      .Syntax_CommentChar = CommentCharacter
  72.      .Syntax_StringChar = StringCharacter
  73.      .Syntax_Delimiter = SplittingCharacter
  74.      .Syntax_Operators = Operators
  75.      .Syntax_LogicalOperators = LOperators
  76.      .Syntax_ReservedWords = RESERVED
  77.      .Syntax_ProceduresORFunctions = FUNC_OBJ
  78.      'Refreshes the syntax coloring always call this property
  79.      'when there is change in Syntaxes or Colors
  80.      .ReColorize
  81. End With
  82. End Sub
  83.  
  84. Public Function OpenURL(urlADD As String, sourceHWND As Long)
  85.      Call ShellExecute(sourceHWND, vbNullString, urlADD, "", vbNullString, 1)
  86. End Function
  87.